<%--
  Created by IntelliJ IDEA.
  User: yiyi
  Date: 2018/8/14
  Time: 15:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改密码</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/css/bootstrap.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
</head>
<body>
    <h2>修改密码</h2>
    <form id="amend">
        <input type="hidden" name="uid" value="${users.id}">
       原密码 <input type="password" id="upassword" placeholder="请输入登录密码"><br>
        新密码 <input type="password" id="pwd" placeholder="请设置新的登录密码"><br>
        确认密码 <input type="password" id="pwd1" name="newspwd"  placeholder="请再次填写密码" onkeyup="validate()" ><span id="tishi"></span><br>
        <a onclick="amend()" class="btn btn-primary">修改</a><a href="#" onclick="history.back()" class="btn btn-primary">返回</a>
    </form>
</body>
<script>
    function validate() {

        var pwd = $("#pwd").val();
        var pwd1 = $("#pwd1").val();
        <!-- 对比两次输入的密码 -->
        if(pwd == pwd1)
        {
            $("#tishi").html("两次密码相同");
            $("#tishi").css("color","green");
            $("#xiugai").removeAttr("disabled");
        }
        else {
            $("#tishi").html("两次密码不相同");
            $("#tishi").css("color","red")
            $("button").attr("disabled","disabled");
        }
    }
 function amend() {
     var data= $("#amend").serialize();
     $.ajax({
         url:"${pageContext.request.contextPath}/admend",
         data:data,
         type:"POST",
         datatype:"json",
         success:function (msg) {
             if (msg.code==404){
                 alert(msg.msg)
             }else if(msg.code==200){
                 alert(msg.msg)
             }
         },
         error:function (msg) {
             alert("修改失败")
         }
     });
 }
</script>
</html>
